import time
from django import template

register = template.Library()


@register.filter
def epoch(value):
    try:
        value = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(value)))
        return(value)
    except Exception as e:
        print(e)
        return '转换失败'


@register.filter
def DomainStatus(value):
    if value == "1":
        return "急需续费"
    elif value == "2":
        return "急需赎回"
    elif value == "3":
        return "正常"
    else:
        return value


@register.filter
def DomainAuditStatus(value):
    if value == "FAILED":
        return "认证失败"
    elif value == "SUCCEED":
        return "认证成功"
    elif value == "NONAUDIT":
        return "未实名认证"
    elif value == "AUDITING":
        return "审核中"
    else:
        return value


@register.filter
def ExpirationDateStatus(value):
    if value == "1":
        return "未过期"
    elif value == "2":
        return "已过期"
    else:
        return value
